<template>
	<view>
		<u-navbar :is-back="false" title="">
			<view class="slot-wrap">
				<view class="back-box" @click="back">
					<view class="icon">
						<u-icon name="arrow-left" color="#999999" size="30"></u-icon>
					</view>
					<view class="back">返回</view>

				</view>
				<view class="title-box">选择助教</view>
				<view class="more-box" @click="handlePutForwardDemand">提出需求</view>
			</view>
		</u-navbar>
		<view class="top-box">
			<view class="top-tip" @click="getRecommendAssistantlist()">
				<view class="">
					<image src="../../static/change.png" mode=""></image>
				</view>
				<view class="text">换一批</view>
			</view>
		</view>
		<view class="list">
			<view class="item" v-for="item in recommendAssistantlist" :key="item.id">
				<BoundCoach :type="4" :data="item" />
			</view>
		</view>
		<div class="btn-box">
			<view class="assistant-buttons">
				<view class="assistant-buttons-content">
					<button @click="show = true">认领助教</button>
				</view>
			</view>
		</div>

		<Pop @handleConfirm="handleConfirm" @handleClosePop="handleClosePop" ok="确认认领" :show="show" title="认领"
			content="确认认领以上助教吗？" contnetDesc="您确认选择该助教，为俱乐部人员吗？" />
	</view>
</template>

<script lang="ts" setup>
	// import AssistantList from '@/componnens/teaching-list-card.vue'
	import { postHttpsRequset } from '@/public-ts-file/request';
	import BoundCoach from '@/componnens/coach-card.vue'
	import Pop from '@/componnens/pop.vue'
	import { ref } from 'vue';
	import { onLoad } from '@dcloudio/uni-app'

	// 获取推荐助教list
	let recommendAssistantlist = ref([])
	const getRecommendAssistantlist = async () => {
		const parms = {
			path: '/shop/Zhujiao/tuijian',
			methods: 'post',
		}
		const res = await postHttpsRequset(parms)
		if (res.code == 200) {
			recommendAssistantlist.value = res.data
		}
	}

	onLoad(() => {
		getRecommendAssistantlist()
	})

	let show = ref(false)

	// 关闭弹窗
	const handleClosePop = (bool : boolean) => show.value = bool

	// 提出需求的
	const handlePutForwardDemand = () => {
		uni.navigateTo({
			url: '/pages/index/assistantDemand'
		})
	}

	const handleConfirm = async (bool : boolean) => {
		const parms = {
			path: '/shop/User/receive',
			methods: 'post',
			data: {
				list: recommendAssistantlist.value
			}
		}
		if (bool) {
			const res = await postHttpsRequset(parms)
			// if (res.code == 200) {
			uni.switchTab({
				url: '/pages/home/index'
			})
			// }

		}
	}

	// 返回
	const back = () => uni.navigateBack()
</script>

<style lang="scss" scoped>
	.list {
		padding: 0 56rpx;
	}

	.top-box {
		display: flex;
		justify-content: flex-end;
		padding-bottom: 26rpx;

		.top-tip {
			display: flex;
			align-items: center;
			padding-right: 30rpx;
		}

		image {
			width: 30rpx;
			height: 30rpx;
			padding-top: 10rpx;
		}

		.text {
			opacity: 1;
			/** 文本1 */
			font-size: 10px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 14.48px;
			color: rgba(153, 153, 153, 1);
			text-align: left;
			vertical-align: top;
			padding-left: 10rpx;
		}
	}

	.slot-wrap {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;

		.title-box {
			opacity: 1;
			/** 文本1 */
			font-size: 16px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 23.17px;
			color: rgba(0, 0, 0, 1);
		}

		.more-box {
			opacity: 1;
			/** 文本1 */
			font-size: 10px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 14.48px;
			color: rgba(0, 0, 0, 1);
			padding-right: 28rpx;
		}

		.back-box {
			display: flex;
			align-items: center;
			padding-left: 28rpx;

			.back {
				opacity: 1;
				/** 文本1 */
				font-size: 10px;
				font-weight: 400;
				letter-spacing: 0px;
				line-height: 14.48px;
				color: rgba(0, 0, 0, 1);
			}
		}

		/* 如果您想让slot内容占满整个导航栏的宽度 */
		/* flex: 1; */
		/* 如果您想让slot内容与导航栏左右有空隙 */
		/* padding: 0 30rpx; */

	}

	.btn-box {
		position: fixed;
		bottom: 12rpx;
		left: 0;
		right: 0;
		box-shadow: rgba(0, 0, 0, 0.06) 0px 2px 4px 0px inset;

		.assistant-buttons {
			margin: 0 30rpx;
			margin-top: 12rpx;

			.assistant-buttons-content {
				button {
					background-color: #3377FE;
					color: white;
					border-radius: 100rpx;
					font-size: 28rpx;
					padding: 8rpx 0;

					&::after {
						display: none;
					}
				}
			}
		}
	}
</style>